#include"head.h"

ret_md5_t create_md5(char *filename,char *username,char *path)
{
    int ret_m = 0 ;
    ret_md5_t ret ;
    ret.check_value = 0 ;
    bzero(ret.md5_val,sizeof(ret.md5_val)) ;

    char buf[1024];
    bzero(buf,sizeof(buf)) ;

    strcat(buf,filename);
    strcat(buf,username);
    strcat(buf,path);

    MD5_CTX c;
    ret_m = MD5_Init(&c);
    if(ret_m != 1 )
    {
        ret.check_value = -1;
        printf("MD5_Init failed\n") ;

		return ret;
    }

    ret_m = MD5_Update(&c,buf,sizeof(buf));
    if(ret_m != 1 )
    {
        ret.check_value = -1;
        printf("MD5_Init failed\n") ;

		return ret;
    }
    
    ret_m = MD5_Final(ret.md5_val,&c);
    if(ret_m != 1 )
    {
        ret.check_value = -1;
        printf("MD5_Init failed\n") ;

		return ret;
    }

    else
    {
        return ret ;
    }


}